package com.demo.web.modules.sys;

import com.demo.common.constant.api.base.IDEntity;
import com.demo.common.constant.api.SysCatalogAPIConstant;
import com.demo.common.result.ResponseInfo;
import com.demo.common.result.ResultVo;
import com.demo.service.sys.SysCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@RestController
@RequestMapping("/sys/catalog")
public class SysCatalogController {
    @Autowired
    private SysCatalogService cataService;

    @GetMapping("/test")
    public String test(){
        return "hello, you are in SyCatalog test!";
    }

    //******************************************************************
    // 字典分类表
    //******************************************************************
    //查询状态类型
    @RequestMapping(value = SysCatalogAPIConstant.STATUS_TYPE_API, method = RequestMethod.POST)
    public ResultVo getStatusTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getStatusTypeCatalogList());
    }

    //查询职位类型
    @RequestMapping(value = SysCatalogAPIConstant.POSITION_TYPE_API, method = RequestMethod.POST)
    public ResultVo getPositionTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getPositionTypeCatalogList());
    }

    //查询公司类型
    @RequestMapping(value = SysCatalogAPIConstant.COMPANY_TYPE_API, method = RequestMethod.POST)
    public ResultVo getCompanyTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getCompanyTypeCatalogList());
    }


    //查询图形类型，图标、图像
    @RequestMapping(value = SysCatalogAPIConstant.GRAPH_TYPE_API, method = RequestMethod.POST)
    public ResultVo getGraphTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getGraphTypeCatalogList());
    }

    //查询性别类型
    @RequestMapping(value = SysCatalogAPIConstant.SEX_TYPE_API, method = RequestMethod.POST)
    public ResultVo getSexTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getSexTypeCatalogList());
    }

    //查询菜单类型
    @RequestMapping(value = SysCatalogAPIConstant.MENU_TYPE_API, method = RequestMethod.POST)
    public ResultVo getMenuTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getMenuTypeCatalogList());
    }

    //查询图标类型
    @RequestMapping(value = SysCatalogAPIConstant.ICON_TYPE_API, method = RequestMethod.POST)
    public ResultVo getIconTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getIconTypeCatalogList());
    }

    //查询图元类型
    @RequestMapping(value = SysCatalogAPIConstant.TUPLE_TYPE_API, method = RequestMethod.POST)
    public ResultVo getTupleTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getTupleTypeCatalogList());
    }

    //应用领域分类
    @RequestMapping(value = SysCatalogAPIConstant.FIELD_TYPE_API, method = RequestMethod.POST)
    public ResultVo getFieldTypeCatalogList() {
        return ResponseInfo.<Object>success(cataService.getFieldTypeCatalogList());
    }

    //查询权限组件分类
    @RequestMapping(value = SysCatalogAPIConstant.PERMISSION_COMPONENT_TYPE_API, method = RequestMethod.POST)
    public ResultVo getPermissionComponentTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getPermissionComponentTypeCatalogList());
    }

    //查询权限操作分类
    @RequestMapping(value = SysCatalogAPIConstant.PERMISSION_OPERATE_TYPE_API, method = RequestMethod.POST)
    public ResultVo getPermissionOperateTypeCatalogList() {
        return ResponseInfo.<Object>success(cataService.getPermissionOperateTypeCatalogList());
    }

    //******************************************************************
    // 普通表
    //******************************************************************
    @RequestMapping(value = SysCatalogAPIConstant.COMPANY_LIST_API, method = RequestMethod.POST)
    public ResultVo getCompanyCatalogList(){
        return ResponseInfo.<Object>success(cataService.getCompanyCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.DEPARTMENT_LIST_API, method = RequestMethod.POST)
    public ResultVo getDepartmentCatalogList(){
        return ResponseInfo.<Object>success(cataService.getDepartmentCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.USER_LIST_API, method = RequestMethod.POST)
    public ResultVo getUserCatalogList(){
        return ResponseInfo.<Object>success(cataService.getUserCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.ROLE_LIST_API, method = RequestMethod.POST)
    public ResultVo getRoleCatalogList(){
        return ResponseInfo.<Object>success(cataService.getRoleCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.MENU_LIST_API, method = RequestMethod.POST)
    public ResultVo getMenuCatalogList(){
        return ResponseInfo.<Object>success(cataService.getMenuCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.ICON_LIST_API, method = RequestMethod.POST)
    public ResultVo getIconCatalogList(){
        return ResponseInfo.<Object>success(cataService.getIconCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.DICT_TYPE_LIST_API, method = RequestMethod.POST)
    public ResultVo getDictionaryTypeCatalogList(){
        return ResponseInfo.<Object>success(cataService.getDictionaryTypeCatalogList());
    }

    @RequestMapping(value = SysCatalogAPIConstant.ICON_SEARCH_LIST_API, method = RequestMethod.POST)
    public ResultVo getIconCatalogListByTypeId(@RequestBody IDEntity<Long> idt){
        Long id = idt.getId();
        System.out.print(id);
        return ResponseInfo.<Object>success(cataService.getIconCatalogListByTypeId(id));
    }

    @RequestMapping(value = SysCatalogAPIConstant.TUPLE_SEARCH_LIST_API, method = RequestMethod.POST)
    public ResultVo getTupleCatalogListByTypeId(@RequestBody IDEntity<Long> idt){
        Long id = idt.getId();
        System.out.print(id);
        return ResponseInfo.<Object>success(cataService.getTupleCatalogListByTypeId(id));
    }

    @RequestMapping(value = SysCatalogAPIConstant.PERMISSION_SEARCH_LIST_API, method = RequestMethod.POST)
    public ResultVo getPermissionCatalogListByMasterId(@RequestBody Map<String, Object> map) {
        return ResponseInfo.<Object>success(cataService.getPermissionCatalogListByMasterId(map));
    }

}
